package com.olap.starter.common.service.crud.impl.builder;

import com.olap.starter.common.service.cache.TableConfigCaCheService;
import com.olap.starter.common.vo.QueryParameter;
import com.olap.starter.pojo.TableConfig;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Log4j2
public class CRUDServiceTableConfigBuilder extends ExecuteWhereBuilder {

    @Autowired
    private TableConfigCaCheService tableConfigCaCheService;
    public void execute(QueryParameter queryParameter) {
        TableConfig config = tableConfigCaCheService.getTableConfig(queryParameter.getId(), queryParameter.getTheme());
        queryParameter.setSql(config.getExecuteSql());
        queryParameter.setOrderByStr(config.getOrderBy());
        setExecuteWhere(config.getExecuteWhere(), queryParameter);
        queryParameter.setDbName(config.getDbName());
    }

}
